import * as vscode from 'vscode';

export class ToolsViewProvider implements vscode.TreeDataProvider<ToolItem> {
    private _onDidChangeTreeData: vscode.EventEmitter<ToolItem | undefined | null | void> = new vscode.EventEmitter<ToolItem | undefined | null | void>();
    readonly onDidChangeTreeData: vscode.Event<ToolItem | undefined | null | void> = this._onDidChangeTreeData.event;

    getTreeItem(element: ToolItem): vscode.TreeItem {
        return element;
    }

    getChildren(element?: ToolItem): Thenable<ToolItem[]> {
        if (element) {
            return Promise.resolve([]);
        }

        return Promise.resolve([
            new ToolItem(
                "分析代码",
                "deepseek.analyzeCode",
                vscode.TreeItemCollapsibleState.None
            ),
            new ToolItem(
                "建议改进",
                "deepseek.suggestChanges",
                vscode.TreeItemCollapsibleState.None
            ),
            new ToolItem(
                "生成代码片段",
                "deepseek.generateSnippet",
                vscode.TreeItemCollapsibleState.None
            ),
            new ToolItem(
                "分析代码库",
                "deepseek.analyzeCodebase",
                vscode.TreeItemCollapsibleState.None
            )
        ]);
    }
}

class ToolItem extends vscode.TreeItem {
    constructor(
        public readonly label: string,
        commandId: string,
        public readonly collapsibleState: vscode.TreeItemCollapsibleState
    ) {
        super(label, collapsibleState);
        
        this.command = {
            title: label,
            command: commandId,
            arguments: []
        };

        this.iconPath = new vscode.ThemeIcon('tools');
        
        this.tooltip = label;
    }
} 